package com.gitee.dupe.authority.service.impl;

import com.gitee.dolt.boot.service.SuperCacheServiceImpl;
import com.gitee.dupe.authority.dao.OrgMapper;
import com.gitee.dupe.authority.entity.Org;
import com.gitee.dupe.authority.service.IOrgService;
import com.gitee.dupe.common.cache.CacheKeyDefinition;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author LYH
 * @since 2020-06-30
 */
@Service
public class OrgServiceImpl extends SuperCacheServiceImpl<OrgMapper, Org> implements IOrgService {

    @Override
    protected String prefix() {
        return CacheKeyDefinition.ORG;
    }

    @Override
    public Map<Serializable, Object> findOrgItem(Set<Serializable> ids) {
        return findByIds(ids, ss -> listByIds(ss))
                .stream().collect(Collectors.toMap(Org::getId, Org::getName));
    }


}
